<?php

class GroupMail extends TPage
{
	public function onLoad($params)
	{
		parent::onLoad($params);
	}
	
	public function sendButtonClicked()
	{
		$user_manager = $this->Application->Modules['users'];
		$users = $user_manager->getUsersList();
		$overal_result = true;
		
		foreach($users as $user)
		{
			$result = Sendmail::send_mail($user->getEmail(), String::format($this->title->Text), $this->text->Text);
			$overal_result = $overal_result && $result;
		}
		
		if($overal_result)
		{
			$this->title->Text = '';
			$this->text->Text = '';
			$this->info->Text = '<p>'.Prado::localize('E-mails sent').'</p>';
		}
		else
			$this->info->Text = '<p>'.Prado::localize('E-mails not sent').'</p>';
	}
}

?>